package com.yango.logistics.controller;

import com.yango.logistics.pojo.Logistics;
import com.yango.logistics.properties.LogisticsProperties;
import com.yango.logistics.service.LogisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RefreshScope
@RestController
public class LogisticsController {
    @Autowired
    private LogisticsService logisticsService;
    @GetMapping("/logistics")
    public Logistics getOrderLogistics(@RequestParam("orderId") Long orderId){
        Logistics logistics = logisticsService.createLogistics(orderId);
        return logistics;
    }
    @Autowired
    private LogisticsProperties logisticsProperties;
    @GetMapping("/config")
    public String getConfig(){
        return "timeout:" + logisticsProperties.getTimeout()+"; auto-confirm："+logisticsProperties.getAutoConfirm();
    }
}
